﻿using HotelRegistrationSystem.DAL;
using HotelRegistrationSystem.Models;
using System.Web.Mvc;

namespace HotelRegistrationSystem.Controllers
{
    public class HomeController : Controller
    {
        [HttpGet]
        [AllowAnonymous]
        public ActionResult Index()
        {
            HotelSearchModel model = (HotelSearchModel)Session["SearchSession"];
            SetHotelSearchModelViewBags(model);
            return View(model);
        }

        [HttpGet]
        [AllowAnonymous]
        public ActionResult Contact()
        {
            return View();
        }

        private void SetHotelSearchModelViewBags(HotelSearchModel model)
        {
            ViewBag.HotelTypeId = new SelectList(HotelDAL.GetHotelTypes(), "HotelTypeId", "Type",
                model == null ? null : model.HotelTypeId);
            ViewBag.ReservationTypeId = new SelectList(ReservationsDAL.GetReservationTypes(), "ReservationTypeId", "Type",
                model == null ? null : model.ReservationTypeId);
            ViewBag.AddressId = new SelectList(AddressDAL.GetAddressByCities(), "AddressId", "City",
                model == null ? null : model.AddressId);
        }
    }
}